package cn.org.spring.wechar.bean;

/**
 * @author： 谢辉
 * @date： 2021/5/10
 * @email: xieh_mail@163.com
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
public class Result<T> {
    private Integer code;
    private String message;
    private T data;


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }


    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <T> Result ok(T t) {
        Result result = new Result<T>();
        result.setCode(1000);
        result.setMessage("成功");
        result.setData(t);
        return result;
    }

    public static Result fail(String msg) {
        Result result = new Result();
        result.setCode(1001);
        result.setMessage(msg);
        return result;
    }


    public Result() {
    }

    public Result(Integer code, String msg) {
        this.code = code;
        this.setMessage(msg);
    }

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.data = data;
        this.setMessage(msg);
    }

}
